<template>
  <div class="workContainer">
    <div class="handle-box" style="text-align: center;margin-top: -15px;margin-left:20px;margin-left:40px">
      <el-input placeholder="请输入工单编号" v-model="inputNum" clearable size="mini" style="width: 150px;margin-right: 20px"></el-input>
      <el-button type="primary" icon="el-icon-plus" @click="addWork" size="mini">导入工单</el-button>
      <el-button type="primary" icon="el-icon-edit" @click="check" size="mini">检查</el-button>
      <el-button type="primary" icon="el-icon-success" @click="push" size="mini">提交</el-button>
    </div>
    <el-form class="suggestionForm" ref="serveForm" :model="formData1"
             :rules="rules" size="mini" label-width="150px" style="margin-top: 5px"
             v-loading="loading" element-loading-text="正在提交检查……"
             element-loading-spinner="el-icon-loading" element-loading-background="rgba(238,241,246,0.8)">
      <el-row class="el-row1">
        <el-col :span="8">
          <el-form-item label="接单人员：" prop="name">
            <el-input v-model="formData1.name" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="接单部门：" prop="department">
            <el-input v-model="formData1.department" :disabled="true"></el-input>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="受理时间：" prop="processTime">
            <el-input v-model="formData1.processTime" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -25px">
        <el-col :span="8">
          <el-form-item label-width="0" prop="selects" style="margin-left: 60px">
            <el-radio v-model="formData1.selects" label="重大事件" style="margin-left: 10px">重大事件</el-radio>
            <el-radio v-model="formData1.selects" label="敏感工单" style="margin-left: 20px">敏感工单</el-radio>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label-width="120px" label="是否约时工单：" prop="ifAppoint" style="margin-left: 30px">
            <el-input v-model="formData1.ifAppoint" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label-width="95px" label="约时时间：" prop="appointTime" style="margin-left: 55px">
            <el-input v-model="formData1.appointTime" clearable :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex" justify="start" align="top" style="margin-top: -25px">
        <el-col :span="8">
          <el-form-item label="一级分类：" prop="kind1">
            <el-input v-model="formData1.kind1" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="二级分类：" prop="kind2">
            <el-input v-model="formData1.kind2" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="三级分类：" prop="kind3">
            <el-input v-model="formData1.kind3" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -25px">
        <el-col :span="16">
          <el-form-item label="关键词：" prop="keywords">
            <el-select v-model="formData1.keywords"  clearable :style="{width: '100%'}">
              <el-option v-for="(item, index) in c1Options" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -20px">
        <el-col :span="16">
          <el-form-item label="回退责任归属：" prop="duty">
            <el-select v-model="formData1.duty"  clearable :style="{width: '100%'}">
              <el-option v-for="(item, index) in c1Options" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -20px">
        <el-col :span="20">
          <el-form-item label="常用意见：" prop="commonSuggestion">
            <el-cascader :options="commonOptions" v-model="formData1.commonSuggestion" style="width: 100%">
              <template #default="{ node, data }">
                <span>{{ data.label }}</span>
                <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
              </template>
            </el-cascader>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -20px">
        <el-col :span="24">
          <el-form-item label="处理情况：" prop="handleInformation" class="handleInformation">
            <div class="but2">
              <el-row><el-button type="primary" icon="el-icon-edit" @click="edit()" size="mini" class="butS">编辑</el-button></el-row>
              <el-row><el-button type="primary" icon="el-icon-success" @click="save()" size="mini" class="butS">保存</el-button></el-row>
            </div>
            <div class="el-textarea el-input&#45;&#45;mini ">
              <textarea id="editText" class="el-textarea__inner "  v-model="formData1.handleInformation" autocomplete="off"  style="min-height: 30px; height: 30px;"></textarea>
<!--              栗明改的-->
              <label id="saveLabel" style="height: 200px"></label>
            </div>
<!--            <el-input v-model="formData1.handleInformation" type="textarea"-->
<!--                      :autosize="{minRows: 1, maxRows: 1}" :style="{width: '100%'}"></el-input>-->
          </el-form-item>
<!--          <p class="processRemind">{{this.processRemind}}</p>-->
          <p class="processRemind" v-html="this.processRemind"></p>
        </el-col>
      </el-row>
      <el-row style="margin-top: -6px">
        <el-col :span="8">
          <el-form-item label="处理结果：" prop="result">
            <el-select v-model="formData1.result"  clearable :style="{width: '100%'}">
              <el-option v-for="(item, index) in resultOptions" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -20px">
        <el-col :span="8">
          <el-form-item label="责任单位：" prop="responsible">
            <el-select v-model="formData1.responsible" placeholder="瓜沥供电所" clearable :style="{width: '100%'}">
              <el-option v-for="(item, index) in c1Options" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="管理归属：" prop="manage">
            <el-select v-model="formData1.manage" placeholder="营销" clearable :style="{width: '100%'}">
              <el-option v-for="(item, index) in c1Options" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="其他部门：" prop="otherDepartment">
            <el-input v-model="formData1.otherDepartment" clearable></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -25px">
        <el-col :span="24">
          <el-form-item label="客户意见：" prop="clientSuggestion" class="clientSuggestion">
            <el-input v-model="formData1.clientSuggestion" type="textarea"
                      :autosize="{minRows: 1, maxRows: 1}" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -15px">
        <el-col :span="24">
          <el-form-item label="承办意见：" prop="sugg3">
            <el-input v-model="formData1.sugg3" type="textarea"
                      :autosize="{minRows: 1, maxRows: 1}" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -20px">
        <el-col :span="8">
          <el-form-item label="附件：" prop="fujian">
            <el-input v-model="formData1.fujian"  clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label-width="0" prop="field145">
            <el-button type="text"  size="mini" color="black"> 查看 </el-button>
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label-width="0" prop="field146">
            <el-button type="text"  size="mini" > 删除 </el-button>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -25px">
        <el-col :span="8">
          <el-form-item label="所属区县："   prop="country">
            <el-input v-model="formData1.country" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -25px">
        <el-col :span="8">
          <el-form-item label="供电所："  prop="powerSupply">
            <el-select v-model="formData1.powerSupply" clearable :style="{width: '100%'}">
              <el-option v-for="(item, index) in powerOptions" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="城农网标志：" prop="logo" label-width="150px">
            <el-select v-model="formData1.logo"  clearable :style="{width: '100%'}">
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="客户编号1：" prop="clientNum" label-width="150px">
            <el-input v-model="formData1.clientNum"  clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -25px">
        <el-col :span="8" >
          <el-form-item label="是否最终答复："  prop="answer">
            <el-select v-model="formData1.answer" :style="{width: '100%'}">
              <el-option v-for="(item, index) in field167Options" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="关联停电信息：" prop="powerCut" >
            <el-input v-model="formData1.powerCut"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -25px">
        <el-col :span="8">
          <el-form-item label="是否属实：" prop="verify">
            <el-select v-model="formData1.verify">
              <el-option v-for="(item, index) in field167Options" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="是否电力公司责任：" prop="dlDuty">
            <el-select v-model="formData1.dlDuty"  clearable
                       :style="{width: '100%'}" >
              <el-option v-for="(item, index) in field167Options" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: -20px">
        <el-col :span="24" >
          <el-form-item label="最终答复内容：" prop="answerContent">
            <el-input v-model="formData1.answerContent" type="textarea"
                      :autosize="{minRows: 1, maxRows: 1}" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <div style="margin-top: -10px;margin-left: 50px">
        <el-table :data="tableData" height="50" border style="width: 100%" class="serverTable">
          <el-table-column prop="num" label="客户编号" width="180" align="center" />
          <el-table-column prop="name" label="客户名称" width="180" align="center"/>
          <el-table-column prop="tel1" label="联系电话" width="180" align="center"/>
          <el-table-column prop="tel2" label="联系电话2" width="180" align="center"/>
          <el-table-column prop="tel3" label="联系电话3" width="180" align="center"/>
          <el-table-column prop="address" label="地址" align="center"/>
        </el-table>
      </div>
    </el-form>
  </div>
</template>
<script>
import {fetchTable, templateKind, checkSuggestion, pushSuggestion, pushServer} from "../../api/api";
import {getDateForm, dateToUnix} from "../../utils/validate";
export default {
  components: {},
  props: [],
  data() {
    return {
      // gdnum1: '1',
      // gdnum2: '210418798714'
      processRemind:'',
      loading: false,
      wrongStr: '',
      sheetId: '',
      inputNum:'',
      tableData: [],
      commonOptions:[],//常用意见的级联下拉框
      kind1Arr: [],//存储所有一级分类数据
      kind1children: [],//存储所有一级分类下的二级分类数据
      kind1Options: [],// 存储所有一级分类的下拉框数据
      kindOptions:[],// 存储所有类别信息
      formData1: {
        name: '',
        department: '',
        processTime: '',
        selects: '',
        ifAppoint: '',
        appointTime: '',
        kind1: '',
        kind2: '',
        kind3: '',
        keywords: '',
        duty: '',
        commonSuggestion: '',
        handleInformation: '',
        result: '',
        responsible: '',
        clientSuggestion:  '',
        sugg3: '',
        fujian: '',
        powerSupply: '',
        clientNum: '',
        logo: '',
        manage: '',
        otherDepartment:'',
        country: "萧山区",
        powerCut: '',
        field164: "用电",
        verify: '是',
        dlDuty: '是',
        answer: '是',
        answerContent: '',
      },
      rules: {
        name: [{required: true, message: '', trigger: 'change'}],
        department: [{required: true, message: '', trigger: 'change'}],
        processTime: [{required: true, message: '', trigger: 'change'}],
        kind1: [{required: true, message: '', trigger: 'change'}],
        kind2: [{required: true, message: '', trigger: 'change'}],
        kind3: [{required: true, message: '', trigger: 'change'}],
        duty: [{required: false, message: '', trigger: 'change'}],
        responsible: [{required: true, message: '', trigger: 'change'}],
        fujian: [{required: false, message: '', trigger: 'change'}],
        c1: [{required: true, message: '', trigger: 'change'}],
        selects: [],
        yueshiOptions: [{required: true, message: '', trigger: 'change'}],
        sugg1: [],
        result: [{required: true, message: '', trigger: 'change'}],
        clientSuggestion: [{required: false, message: '', trigger: 'change'}],
        sugg3: [{required: true, message: '', trigger: 'change'}],
        qingkuang: [{required: true, message: '', trigger: 'change'}],
        field161: [{required: true, message: '', trigger: 'change'}],
        powerSupply: [{required: true, message: '', trigger: 'blur'}],
        clientNum: [{required: true, message: '', trigger: 'blur'}],
        logo: [{required: false, message: '', trigger: 'change'}],
        powerCut: [{required: false, message: '', trigger: 'change'}],
        answer: [{required: false, message: '', trigger: 'change'}],
        verify: [{required: true, message: '', trigger: 'change'}],
        dlDuty: [{required: true, message: '', trigger: 'change'}],
        answerContent: [{required: false, message: '', trigger: 'blur'}],
      },
        c1Options: [{"label": '', "value": 1}, {"label": '', "value": 2}, {"label": '', "value": 3}, {"label": '', "value": 4}],
        resultOptions: [{"label": "处理完成", "value": 1}, {"label": "未处理", "value": 2}, {"label": "正在处理", "value": 3}],
        sugg1Options: [{"label": "选项一", "value": 1}, {"label": "选项二", "value": 2}],
        powerOptions:[{"label": "湘湖供电所", "value": 1}, {"label": "临浦供电所", "value": 2},
                      {"label": "瓜沥供电所", "value": 3}, {"label": "钱江供电所", "value": 4}],
        field167Options: [{"label": "是", "value": '是'}, {"label": "否", "value": '否'}],
    }
  },
  computed: {},
  watch: {},
  created() {
    this.getKindMsg()
  },
  mounted() {},
  methods: {
    // check接口
    check(){
      if (this.inputNum){
        this.loading = true
        this.processVisible = false
        this.processRemind = ''
        let param = {
          sdSubmityjYsDggdId: this.sheetId,
          sdSubmityjNumber: this.inputNum,
          sdSubmityjJdry: this.formData1.name,
          sdSubmityjJdbm: this.formData1.department,
          sdSubmityjSlsj: dateToUnix(this.formData1.processTime),
          sdSubmityjYjfl: this.formData1.kind1,
          sdSubmityjEjfl: this.formData1.kind2,
          sdSubmityjSjfl: this.formData1.kind3,
          sdSubmityjGjc: this.formData1.keywords,
          sdSubmityjZdsjmggd: this.formData1.selects,
          sdSubmityjHtzrgs: this.formData1.duty,
          sdSubmityjCyyj: this.formData1.commonSuggestion,
          // sdSubmityjYssj: this.formData1.appointTime == '' ? 1: dateToUnix(this.formData1.appointTime),
          sdSubmityjYssj:dateToUnix(this.formData1.appointTime),
          sdSubmityjSfysgd: this.formData1.ifAppoint,
          sdSubmityjClqk: this.formData1.handleInformation,
          sdSubmityjCljg: this.formData1.result,
          sdSubmityjZrdw: this.formData1.responsible,
          sdSubmityjGlgs: this.formData1.manage,
          sdSubmityjQtbm: this.formData1.otherDepartment,
          sdSubmityjKhyj: this.formData1.clientSuggestion,
          sdSubmityjSsqx: this.formData1.country,
          sdSubmityjGds: this.formData1.powerSupply,
          sdSubmityjSfzzdf: this.formData1.answer,
          sdSubmityjSfss: this.formData1.verify,
          sdSubmityjSfdlgsdzr: this.formData1.dlDuty,
          sdSubmityjZzdfnr: this.formData1.answerContent,
          sdSubmityjKhmc: this.tableData[0].name,
          sdSubmityjKhbh: this.tableData[0].num,
          sdSubmityjKhdz: this.tableData[0].address,
          sdSubmityjKhlxdh: this.tableData[0].tel1
        }
        console.log('check的参数', param)
        checkSuggestion(param).then(res=>{
          console.log('意见check接口数据：', res.data)
          if (res.data.msg == '处理情况填写错误'){
            this.loading = false
            this.$notify({title: 'check完成', message: '请按照页面提示内容修改表单', type: 'warning'});
            let remind = ''
            let index = 1
            let msg_content=''
            res.data.data.forEach(msg=>{
              console.log('msg=', msg)
              // remind = remind + (index++)+'.' + msg
              // 栗明改的
              msg_content=(index++) + '.' + msg
              msg_content=msg_content.replace(msg_content,msg_content+'<br/>')
              remind= remind +msg_content
              console.log('remind = ',remind)
            })
            this.processRemind = remind
            this.processVisible = true
          }else if (res.data.msg == '有错别字') {
            this.loading = false
            this.processRemind = '错别字：'+ res.data.data[0][0] + '-->' + res.data.data[0][1]
            this.processVisible = true
            this.wrongStr = res.data.data[0][0]
            for (let i = 1; i < res.data.data.length; i++){
              this.wrongStr += '，'+ res.data.data[i][0]
            }
            console.log('handleInformation:'+ this.formData1.handleInformation + 'wrongStr:' + this.wrongStr)
          }
          if (res.data.status == 200){
            this.loading = false
            this.processRemind = false
            this.processRemind = ''
            this.$notify({title: '检查通过', message: '页面已检查通过，可以提交！', type: 'success'})
          }
        })
      }else {
        this.$message.info('未输入工单编号！')
      }

    },
    // 获取所有模板的类别信息
    getKindMsg() {
      this.commonOptions = []
      this.kind1Arr = []
      this.kindOptions = []
      templateKind().then((res) => {
        res.data.data.forEach((item)=>{
          if(item.sdMblbYwlx == 1 && item.sdMblbEjflName!=null){
            let dict = {
              kind1: item.sdMblbYjflName,
              kind2: item.sdMblbEjflName
            }
            this.kindOptions.push(dict)
            this.kind1Arr.push(item.sdMblbYjflName)
          }
        })
        this.kind1Arr = [...new Set(this.kind1Arr)]
        this.kind1Arr.forEach((item)=>{
          this.kind1children = []
          this.kindOptions.forEach((arr)=>{
            if(item == arr.kind1){
              let child = {
                value: arr.kind2,
                label: arr.kind2,
              }
              this.kind1children.push(child)
            }
          })
          let y = {
            value: item,
            label: item,
            children: this.kind1children
          }
          this.commonOptions.push(y)
        })
      })
    },
    addWork(){
      if (this.inputNum) {
        fetchTable(1,this.inputNum).then((res)=>{
          if(res.data.status === 200){
            this.$message.success('导入' + this.inputNum + '号工单成功！')
            console.log('意见工单数据', res.data.data)
            this.sheetId = res.data.data.sdDggdId
            this.formData1.name = res.data.data.sdDggdJdry //接单人员
            this.formData1.department = res.data.data.sdDggdJdbm//接单部门
            this.formData1.processTime = getDateForm(res.data.data.sdDggdSlsj)//受理时间
            this.formData1.handleInformation = res.data.data.sdDggdClqk //处理情况
            this.formData1.clientSuggestion = res.data.data.sdDggdKhyj //客户意见
            this.formData1.country = res.data.data.sdDggdSsqx //所属县区
            this.formData1.clientNum = res.data.data.sdDggdKhbh //客户编号1
            this.processRemind = ''
            document.getElementById("editText").style.display = "none"
            document.getElementById("saveLabel").style.display = "block"
            document.getElementById("saveLabel").innerHTML = res.data.data.sdDggdClqk
            let labelContent = document.getElementById("saveLabel").innerHTML
            let end_index=labelContent.indexOf("处理结果")
            let str = labelContent.substring(labelContent.indexOf("处理经过") - 2, labelContent.indexOf("处理结果") - 2)

            // 栗明改的
            if (end_index>0) {
              labelContent = labelContent.replace(str, '<font color="red">' + str + '</font>')
            }
            document.getElementById("saveLabel").innerHTML = labelContent

            const table = {
              num: res.data.data.sdDggdKhbh,
              name: res.data.data.sdDggdKhmc,
              tel1: res.data.data.sdDggdKhlxdh,
              tel2: '',
              tel3: '',
              address: res.data.data.sdDggdKhdz
            };
            this.tableData.push(table)
          }else {
            this.$message.error('导入' + this.inputNum + '号工单失败！')
          }
        })
      }else {
        this.$message.info('未输入工单编号！')
      }
    },
    submitForm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        // TODO 提交表单
      })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
    edit() {
      document.getElementById("editText").style.display = "block"
      document.getElementById("saveLabel").style.display = "none"
    },
    save() {
      document.getElementById("editText").style.display = "none"
      document.getElementById("saveLabel").style.display = "block"
      document.getElementById("saveLabel").innerHTML = document.getElementById("editText").value
      let labelContent = document.getElementById("saveLabel").innerHTML

      //保存之后还需标红？？？
      // let str = labelContent.substring(labelContent.indexOf("处理经过") - 2, labelContent.indexOf("处理结果") - 2)
      // labelContent = labelContent.replace(str, '<font color="red">' + str + '</font>')
      document.getElementById("saveLabel").innerHTML = labelContent

      //点击保存按钮的同时将处理情况复制到剪切板
      var input = document.createElement("input");
      input.value = labelContent;
      document.body.appendChild(input);
      input.select();
      document.execCommand("Copy");
      this.$message.success('处理情况已复制到剪切板')
    },
    // 提交工单，0527存在问题！！！
    push() {
      if (this.inputNum){
        this.loading = true
        this.processVisible = false
        this.processRemind = ''
        let param = {
          sdSubmityjYsDggdId: this.sheetId,
          sdSubmityjNumber: this.inputNum,
          sdSubmityjJdry: this.formData1.name,
          sdSubmityjJdbm: this.formData1.department,
          sdSubmityjSlsj: dateToUnix(this.formData1.processTime),
          sdSubmityjYjfl: this.formData1.kind1,
          sdSubmityjEjfl: this.formData1.kind2,
          sdSubmityjSjfl: this.formData1.kind3,
          sdSubmityjGjc: this.formData1.keywords,
          sdSubmityjZdsjmggd: this.formData1.selects,
          sdSubmityjHtzrgs: this.formData1.duty,
          sdSubmityjCyyj: this.formData1.commonSuggestion,
          // sdSubmityjYssj: this.formData1.appointTime == '' ? 1: dateToUnix(this.formData1.appointTime),
          sdSubmityjYssj:dateToUnix(this.formData1.appointTime),
          sdSubmityjSfysgd: this.formData1.ifAppoint,
          sdSubmityjClqk: this.formData1.handleInformation,
          sdSubmityjCljg: this.formData1.result,
          sdSubmityjZrdw: this.formData1.responsible,
          sdSubmityjGlgs: this.formData1.manage,
          sdSubmityjQtbm: this.formData1.otherDepartment,
          sdSubmityjKhyj: this.formData1.clientSuggestion,
          sdSubmityjSsqx: this.formData1.country,
          sdSubmityjGds: this.formData1.powerSupply,
          sdSubmityjSfzzdf: this.formData1.answer,
          sdSubmityjSfss: this.formData1.verify,
          sdSubmityjSfdlgsdzr: this.formData1.dlDuty,
          sdSubmityjZzdfnr: this.formData1.answerContent,
          sdSubmityjKhmc: this.tableData[0].name,
          sdSubmityjKhbh: this.tableData[0].num,
          sdSubmityjKhdz: this.tableData[0].address,
          sdSubmityjKhlxdh: this.tableData[0].tel1
        }
        console.log('check的参数', param)
        checkSuggestion(param).then(res=>{
          console.log('意见check接口数据：', res.data)
          if (res.data.msg == '处理情况填写错误'){
            this.loading = false
            this.$notify({title: '提交失败', message: '请先进行检查', type: 'warning'});
            let remind = ''
            let index = 1
            res.data.data.forEach(msg=>{
              console.log('msg=', msg)
              // remind = remind + (index++)+'.' + msg
              console.log('remind = ',remind)
            })
            this.processRemind = remind
            this.processVisible = true
          }else if (res.data.msg == '有错别字') {
            this.loading = false
            // this.processRemind = '错别字修改建议：'+ res.data.data[0][0] + '-->' + res.data.data[0][1]
            // for (let i = 1; i < res.data.data.length; i++){
            //   this.processRemind += '，'+ res.data.data[i][0] + '-->' + res.data.data[i][1]
            // }
            this.processVisible = true
            this.wrongStr = res.data.data[0][0]
            for (let i = 1; i < res.data.data.length; i++){
              this.wrongStr += '，'+ res.data.data[i][0]
            }
            console.log('handleInformation:'+ this.formData1.handleInformation + 'wrongStr:' + this.wrongStr)
            this.$confirm('还有错别字未修改, 是否继续提交?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
                pushSuggestion(param).then(res => {
                  console.log('push接口数据：', res.data)
                  this.loading = false
                  if (res.data.status == 200) {
                    this.$message.success('提交成功！')
                    this.processVisible = false
                    // this.formData1 = {}
                    // this.processRemind=''
                    this.timeRemind=''
                    // document.getElementById("saveLabel").innerHTML = ''
                  } else {
                    this.$message.error('提交失败！')
                  }
                })
            }).catch(() => {
                this.loading = false
                this.processRemind = '错别字修改建议：'+ res.data.data[0][0] + '-->' + res.data.data[0][1]
                for (let i = 1; i < res.data.data.length; i++){
                  this.processRemind += '，'+ res.data.data[i][0] + '-->' + res.data.data[i][1]
                }
                this.processVisible = true
                this.wrongStr = res.data.data[0][0]
                for (let i = 1; i < res.data.data.length; i++){
                  this.wrongStr += '，'+ res.data.data[i][0]
                }
                console.log('handleInformation:' + this.formData.handleInformation + 'wrongStr:' + this.wrongStr)
                this.$notify({title: '检查通过', message: 'check有错别字存在，已给出修改建议，可提交', type: 'success'});
            });
          }else{
              pushSuggestion(param).then(res => {
                console.log('push接口数据：', res.data)
                this.loading = false
                if (res.data.status == 200) {
                  this.$message.success('提交成功！')

                  const timer = setInterval(() => {
                    if(num < secounds) {
                      num++
                    }else {
                      clearInterval(timer)
                      alert('自定义函数在这里调用')
                    }
                  }, 1000)
                  // 提交成功后刷新界面
                  location.reload()

                  this.processVisible = false
                  // this.formData1 = {}
                  // this.processRemind=''
                  this.timeRemind=''
                  document.getElementById("saveLabel").innerHTML = ''
                } else {
                  this.$message.error('提交失败！')
                }
              })
          }
        })
      }else {
        this.$message.info('未输入工单编号！')
      }
    },
  }
}

</script>
<style>
.workContainer{
  /*padding: 20px 30px 12px 30px;*/
  /*margin-top: 10px;*/
  /*padding: 30px;*/
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 20px 50px 12px 10px;
}
.serverTable tr,
.serverTable th {
  padding: 0;
  height: 20px;
}
.serverTable tr,
.serverTable td {
  padding: 0;
  height: 20px;
}
.serverTable tr,.serverTable td{
  font-size: 1px;
  text-align: center;
}
.suggestionForm .el-form-item__label{
  font-size: 1px;
}
.suggestionForm .el-radio__label{
  font-size: 1px;
}
.suggestionForm .el-select-dropdown__item{
  font-size: 1px;
}
.suggestionForm .el-input--mini .el-input__inner{
  height: 20px;
  line-height: 10px;
}
.clientSuggestion .el-textarea__inner{
  min-height: 15px !important;
  height: 20px !important;
}
.handleInformation .el-textarea__inner{
  /*栗明改的*/
  min-height: 200px !important;
  height: 200px !important;
}
.processRemind{
  color: red;
  font-size: 1px;
  margin-left: 160px;
  margin-top: -15px;
  margin-bottom: 5px;
}
.but2{
  position: absolute;
  top: 20px;
  left: -74px;
}
.butS{
  padding: 4px 10px;
  min-height: 18px;
  margin-top: 3px;
}
#editText{
  display: none;
}

#saveLabel{
  height: 70px;
  width: 100%;
  box-sizing: border-box;
  padding: 5px 15px;
  border: 1px solid #DCDFE6;
  border-radius: 4px;
  display: block;
  font-size: inherit;
  line-height: 1.5;
  overflow: auto;
}
</style>
